package com.rede.didiok.user.controller;

import java.util.Arrays;
import java.util.Map;

// import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.rede.didiok.user.entity.UserAccountEntity;
import com.rede.didiok.user.service.UserAccountService;
import com.rede.didiok.common.utils.PageUtils;
import com.rede.didiok.common.utils.R;



/**
 * 账号绑定表
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-08-07 18:21:17
 */
@RestController
@RequestMapping("user/useraccount")
public class UserAccountController {
    @Autowired
    private UserAccountService userAccountService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("user:useraccount:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userAccountService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{uid}")
    // @RequiresPermissions("user:useraccount:info")
    public R info(@PathVariable("uid") String uid){
		UserAccountEntity userAccount = userAccountService.getById(uid);

        return R.ok().put("userAccount", userAccount);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("user:useraccount:save")
    public R save(@RequestBody UserAccountEntity userAccount){
		userAccountService.save(userAccount);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("user:useraccount:update")
    public R update(@RequestBody UserAccountEntity userAccount){
		userAccountService.updateById(userAccount);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("user:useraccount:delete")
    public R delete(@RequestBody String[] uids){
		userAccountService.removeByIds(Arrays.asList(uids));

        return R.ok();
    }

}
